﻿using LimaLims.Application.Service.Base.Dto;
using LimaLims.Application.Service.Basic.Dto;
using LimaLims.Core;
using LimaLims.Core.Entity.Basic;
using LimaLims.Core.Entity.TestCenter;
using LimaLims.Core.Enum;
using LimaLims.Core.Util;

namespace LimaLims.Application.Service.TestCenter.Dto
{
    /// <summary>
    /// 新增试验计划DTO
    /// </summary>
    public class AddExperimentPlanInput : BaseDto
    {
        /// <summary>
        /// 计划编号
        /// </summary>
        public string Code { get; set; }

        /// <summary>
        /// 班组Id
        /// </summary>
        public long TeamId { get; set; }

        /// <summary>
        /// 计划类型
        /// </summary>
        public ExperimentType Type { get; set; }

        public string TypeText => Type.GetDescription();

        /// <summary>
        /// 计划状态
        /// </summary>
        public ExperimentPlanStatus PlanStatus { get; set; } = ExperimentPlanStatus.NotStarted;

        public string PlanStatusText => PlanStatus.GetDescription();

        /// <summary>
        /// 计划开始时间
        /// </summary>
        public DateTime PlanStartTime { get; set; }

        /// <summary>
        /// 计划完成时间
        /// </summary>
        public DateTime PlanEndTime { get; set; }

        /// <summary>
        /// 试验方案ID
        /// </summary>
        public long InspectionSchemeId { get; set; }

        /// <summary>
        /// 一对多中间表（计划-产品）
        /// </summary>
        public List<long> ProductIds { get; set; }

        /// <summary>
        /// 一对多中间表（计划-物料）
        /// </summary>
        public List<long> MaterialIds { get; set; }
    }

    public class EditExperimentPlanInput : AddExperimentPlanInput
    {

    }

    /// <summary>
    /// 计划详细Model
    /// </summary>
    public class ExperimentPlanModel : AddExperimentPlanInput
    {
        public string TeamName { get; set; }
        /// <summary>
        /// 实际开始时间
        /// </summary>
        public DateTime? ActualStartTime { get; set; }
        /// <summary>
        /// 实际完成时间
        /// </summary>
        public DateTime? ActualEndTime { get; set; }
        public List<long> ProductIds { get; set; }
        public List<long> MaterialIds { get; set; }
    }

    /// <summary>
    /// 计划详细
    /// </summary>
    public class ExperimentPlanDetail
    {
        public InspectionScheme Scheme { get; set; }
        public ExperimentPlanModel PlanModel { get; set; }
        public ICollection<Material> Materials { get; set; }
        public ICollection<ProductOutput> Products { get; set; }
        public ICollection<InspectionDataOutput> InspectionTableData { get; set; }
    }


    /// <summary>
    /// 试验计划列表属性
    /// </summary>
    public class ExperimentPlanOutput
    {
        public long Id { get; set; }

        public string Code { get; set; }

        /// <summary>
        /// 班组Id
        /// </summary>
        public long TeamId { get; set; }

        public string TeamName { get; set; }

        public long InspectionSchemeId { get; set; }
        /// <summary>
        /// 试验方案编号
        /// </summary>
        public string InspectionSchemeCode { get; set; }

        /// <summary>
        /// 计划类型
        /// </summary>
        public ExperimentType Type { get; set; }

        /// <summary>
        /// 计划状态
        /// </summary>
        public ExperimentPlanStatus PlanStatus { get; set; }

        public string PlanStatusText => PlanStatus.GetDescription();

        /// <summary>
        /// 计划开始时间
        /// </summary>
        public DateTime PlanStartTime { get; set; }

        /// <summary>
        /// 计划完成时间
        /// </summary>
        public DateTime PlanEndTime { get; set; }

        /// <summary>
        /// 实际开始时间
        /// </summary>
        public DateTime? ActualStartTime { get; set; }

        /// <summary>
        /// 实际完成时间
        /// </summary>
        public DateTime? ActualEndTime { get; set; }

        /// <summary>
        /// 数量
        /// </summary>
        public int Count { get; set; }

        public bool ValidStatus { get; set; }

        public int Sort { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime? CreatedTime { get; set; }
        /// <summary>
        /// 最后修改时间
        /// </summary>
        public DateTime? UpdatedTime { get; set; }
        /// <summary>
        /// 创建人
        /// </summary>
        public string CreatedUserName { get; set; }

        /// <summary>
        /// 最后修改者
        /// </summary>
        public string UpdatedUserName { get; set; }
    }


    /// <summary>
    /// 试验计划分页
    /// </summary>
    public class ExperimentPlanPageInput : PageInputBase
    {
        public string Code { get; set; }
        /// <summary>
        /// 试验类型
        /// </summary>
        public ExperimentType? Type { get; set; }
        /// <summary>
        /// 计划状态
        /// </summary>
        public ExperimentPlanStatus? PlanStatus { get; set; }
        /// <summary>
        /// 试验方案ID
        /// </summary>
        public long? InspectionSchemeId { get; set; }
    }

}
